/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qdu.servlet;

import com.qdu.dao.UsersDao;
import com.qdu.entity.LogRemark;
import com.qdu.service.impl.LogRemarkServiceImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * 添加新的评论
 *
 * @author Lenovo
 */
@WebServlet("/alrms")
public class addLogRemarkServlet extends HttpServlet{

    LogRemarkServiceImpl logremarkserviceimpl=new LogRemarkServiceImpl();
    UsersDao userdao=new UsersDao();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       
            String id=req.getParameter("logid");
            String content=req.getParameter("content");
            HttpSession session=req.getSession();
             String uid=(String)session.getAttribute("PageUid");
           //获取session的属性，用户id
                if(null==uid){
                    resp.sendRedirect("Userlogin.html");
                }
                else{
                    LogRemark remark=new LogRemark();
                    remark.setId("1");
                    remark.setLogId(id);
                    remark.setAgree(0);
                    remark.setContent(content);
                    remark.setUserName(uid);//设置用户id为用户id
                    int rows=logremarkserviceimpl.addNewRemark(remark);
                    System.out.println(rows);
                    resp.sendRedirect("solfm?logId="+id);
                }
                
            }
     
    }


